home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 66
/
Vol 66.iso
/
games
/
bob_espo.swf
/
scripts
/
__Packages
/
Transition.as
< prev
next >
Wrap
Text File
|
2013-04-24
|
2KB
|
71 lines
class Transition extends State
{
static var sEXCEPTION = "Instructions";
static var sSTATE_IDLE = "Idle";
static var sSTATE_PLAY_LEFT = "PlayLeft";
static var sSTATE_PLAY_RIGHT = "PlayRight";
static var nFRAME_CHANGE = 30;
function Transition(_mcRef)
{
super(_mcRef,false);
this.setState(Transition.sSTATE_IDLE);
this.bIsLeft = !!Math.round(Math.random());
}
function goTo(_sGoingTo, _classToMove)
{
this.sGoingTo = _sGoingTo;
if(!(_classToMove instanceof State) || (_classToMove == undefined || _classToMove == null))
{
this.classToMove = Main.getRef();
}
else
{
this.classToMove = _classToMove;
}
if(this.sState == Transition.sSTATE_IDLE)
{
if(this.bIsLeft)
{
this.setState(Transition.sSTATE_PLAY_RIGHT);
this.bIsLeft = false;
}
else
{
this.setState(Transition.sSTATE_PLAY_LEFT);
this.bIsLeft = true;
}
}
Controller.getRef().getSounds().playSound("SFX_Transition",Controller.nSFX_VOLUME,1);
}
function managePlayAnim()
{
if(this.stateFinished())
{
this.setState(Transition.sSTATE_IDLE);
}
else if(this.mcRef.mcState._currentframe == Transition.nFRAME_CHANGE)
{
if(this.sGoingTo != Transition.sEXCEPTION)
{
Controller.getRef().getInstructions().doHide();
this.classToMove.setState(this.sGoingTo);
}
else
{
Controller.getRef().getInstructions().doShow();
}
}
}
function Idle()
{
}
function PlayLeft()
{
this.managePlayAnim();
}
function PlayRight()
{
this.managePlayAnim();
}
}